package com.wangle.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.pro.bean.Groups;
import com.dao.ObjectDao;

public class MenuServlet extends HttpServlet {

	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Groups groupp =new Groups();
		PrintWriter out = response.getWriter();
		ObjectDao ObjectDao2=new ObjectDao();
		List lUnit=ObjectDao2.findall(groupp);
		Set<Integer> set = new HashSet<Integer>();
		Iterator it = lUnit.iterator();
		List rs = new ArrayList();
		while(it.hasNext())
		{
			Groups g = (Groups)it.next();
			if( set.add(g.getPrgroupid()) )
			{
				System.out.println(g.getPrgroupid());
				rs.add(g);
			}
		}
		request.getSession().setAttribute("list", rs);
			
			out.println("<script>location.href=\"groupMain.html\";</script>");
			
			

	}

	public void init() throws ServletException {
		// Put your code here
	}

}
